#pragma once

#include <memory>
#include "Protocol.hpp"


class NetCal
{
public:
    NetCal()
    {
    }
    ~NetCal()
    {
    }

    std::shared_ptr<Response> Calculator(std::shared_ptr<Request> req)
    {
        auto resp = Factory::BuildResponseDefault();

        switch (req->Oper())
        {
        case '+':
            resp->_result = req->X() + req->Y();
        case '-':
            resp->_result = req->X() - req->Y();
        case '*':
            resp->_result = req->X() * req->Y();
        case '/':
        {
            if (req->Y() == 0)
            {
                resp->_code = 1;
                resp->_desc = "divd zero";
            }
            else
                resp->_result = req->X() / req->Y();
        }
        }
    }
};
